home *** CD-ROM | disk | FTP | other *** search
- //----------------------------------------------------------------------------------
- // File : debugCDEF.c
- // Date : July 23, 1994
- // Author : Jim Stout
- // :
- // Purpose : a dummy CDEF. I forget where I ran across this technique (an old
- // : MacTutor perhaps). The goal here is to be able to test a code
- // : definition with the Think C source debugger.
- //
- // : To do this, you need the CDEF as 'inline' code, not as a code resource.
- // : This is one way to do it. Briefly, here is what to do:
- //
- // : 1. Build this project as a CDEF with id=128 as file debug.rsrc.
- //
- // : 2. Include the CDEF and a custom resource of type 'CJMP', id=128 in
- // : the .rsrc of your test project. The 'CJMP' resouce should be a long.
- // See testGeneric.r
- //
- // : 3. Include your CDEF source code in a test project, but with an entry
- // : point of CDEFmain() instead of main().
- // See genericCDEF.c in project testGeneric π.
- //
- // : 4. In your test source, where main() is found plug the address of
- // : CDEFmain into the 'CJMP' resource.
- // See testGeneric.c in project testGeneric π.
- //
- // : 5. Use 128 as the CDEF id in your resource templates.
- // See testGeneric.r in project testGeneric π.
- //
- // : If you have done things correctly, when the Control Manager tries to
- // : call CDEF 128, it gets this code instead, which recovers the address
- // : of CDEFmain and calls it. The Think Debugger can then be used to
- // : step through the source of your CDEF. When it is working, simply
- // : build your CDEF as a code resource.
- // See genericCDEF π.
- //----------------------------------------------------------------------------------
- #include "debugCDEF.h"
-
- pascal long main (short varCode, ControlHandle theControl, short message, long param)
- {
- CJMPhdl h;
- long result=0;
-
- h = (CJMPhdl)GetResource('CJMP',128);
- if(h != nil) {
- result = CallPascalL(varCode,theControl,message,param,(**h).cdefPtr);
- }
- return result;
- }